import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/pages/common/knowledgeWords.dart';
import 'package:ichinesereader/pages/common/leaderBoard.dart';
import 'package:ichinesereader/pages/common/myBadges.dart';
import 'package:ichinesereader/pages/student/announcements.dart';
import 'package:ichinesereader/utils/helper.dart';
import 'package:ichinesereader/constants.dart';

class FloatingActionButtonsForHome extends StatelessWidget {
  FloatingActionButtonsForHome({
    Key? key,
    required this.isStudent,
  }) : super(key: key);

  final bool isStudent;

  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.end,
      children: <Widget>[
        isStudent
            ? SizedBox(
                height: 45,
                width: 45,
                child: FloatingActionButton(
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(15.0))),
                  backgroundColor: Get.isDarkMode
                      ? Color(0xff000000)
                      : Get.theme.primaryColorDark,
                  heroTag: Text('myannouncements0000'.tr),
                  tooltip: 'Messages'.tr,
                  onPressed: () {
                    Get.to(() => StudentMyAnnouncements());
                  },
                  child: Icon(
                    Icons.message_rounded,
                    color: Get.isDarkMode
                        ? Get.theme.primaryColorLight
                        : Get.theme.primaryColorLight,
                    size: 24,
                  ),
                  elevation: 0,
                  splashColor: Colors.grey,
                ),
              )
            : Text(''),
        SizedBox(width: 9.0),
        isStudent
            ? SizedBox(
                height: 45,
                width: 45,
                child: FloatingActionButton(
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(15.0))),
                  backgroundColor: Get.isDarkMode
                      ? Color(0xff000000)
                      : Get.theme.primaryColorDark,
                  heroTag: Text('FlashCards0000'.tr),
                  tooltip: 'Word Cards'.tr,
                  onPressed: () {
                    //Navigator.pushNamed(context, '/common/flashcards');
                    Get.to(() => KnowledgeWordsPage());
                  },
                  child: Icon(
                    Icons.translate,
                    color: Get.isDarkMode
                        ? Get.theme.primaryColorLight
                        : Get.theme.primaryColorLight,
                    size: 24,
                  ),
                  elevation: 0,
                  splashColor: Colors.grey,
                ),
              )
            : Text(''),
        SizedBox(width: 9.0),
        SizedBox(
          height: 45,
          width: 45,
          child: FloatingActionButton(
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(15.0))),
            backgroundColor:
                Get.isDarkMode ? Color(0xff000000) : Get.theme.primaryColorDark,
            heroTag: Text(
              'Audioplaylist0000'.tr,
            ),
            tooltip: 'Audio playlist'.tr,
            onPressed: () {
              isStudent
                  ? Navigator.pushNamed(context, '/student/audiobooks')
                  : Navigator.pushNamed(context, '/individual/audiobooks');
            },
            child: Icon(
              Icons.music_note_rounded,
              color: Get.isDarkMode
                  ? Get.theme.primaryColorLight
                  : Get.theme.primaryColorLight,
              size: 24,
            ),
            elevation: 0,
            splashColor: Colors.grey,
          ),
        ),
        SizedBox(width: 9.0),
        SizedBox(
          height: 45,
          width: 45,
          child: FloatingActionButton(
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(15.0))),
            backgroundColor:
                Get.isDarkMode ? Color(0xff000000) : Get.theme.primaryColorDark,
            heroTag: Text('badges0000'.tr),
            tooltip: 'Badges'.tr,
            onPressed: () {
              //Navigator.pushNamed(context, '/common/mybadges');
              Get.to(() => MyBadgesPage());
            },
            child: Icon(
              Icons.stars,
              color: Get.isDarkMode
                  ? Get.theme.primaryColorLight
                  : Get.theme.primaryColorLight,
              size: 24,
            ),
            elevation: 0,
            splashColor: Colors.grey,
          ),
        ),
        SizedBox(width: 9.0),
        SizedBox(
          height: 45,
          width: 45,
          child: FloatingActionButton(
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(15.0))),
            backgroundColor:
                Get.isDarkMode ? Color(0xff000000) : Get.theme.primaryColorDark,
            heroTag: Text('leaderboard'.tr),
            tooltip: 'Leader Board'.tr,
            onPressed: () {
              //Navigator.pushNamed(context, '/common/mybadges');
              Get.to(() => LeaderBoardPage());
            },
            child: Icon(
              Icons.leaderboard_rounded,
              color: Get.isDarkMode
                  ? Get.theme.primaryColorLight
                  : Get.theme.primaryColorLight,
              size: 24,
            ),
            elevation: 0,
            splashColor: Colors.grey,
          ),
        ),
        SizedBox(width: 9.0),
        SizedBox(
          height: 45,
          width: 45,
          child: FloatingActionButton(
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(15.0))),
            backgroundColor:
                Get.isDarkMode ? Color(0xff000000) : Get.theme.primaryColorDark,
            heroTag: Text('Game and rewards0000'.tr),
            tooltip: 'Rewards'.tr,
            onPressed: () {
              if (GetPlatform.isWeb) {
                Get.offAllNamed('/student/reward');
              } else if (GetPlatform.isDesktop) {
                launchInWebViewWithJavaScript('${Constants.BaseURL}game/');
              } else {
                Get.offAllNamed('/student/reward');
              }
            },
            child: Icon(
              Icons.videogame_asset,
              color: Get.isDarkMode
                  ? Get.theme.primaryColorLight
                  : Get.theme.primaryColorLight,
              size: 24,
            ),
            elevation: 0,
            splashColor: Colors.grey,
          ),
        ),
      ],
    );
  }
}
